package com.hs.eric.service.impl;

import com.hs.eric.entity.TreeItem;
import com.hs.eric.entity.User;
import com.hs.eric.mapper.UserMapper;
import com.hs.eric.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 * User: eric
 * Date: 2015/4/10
 * Time: 23:05
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    public List<User> getUsers() {
        List<User> users = userMapper.getAllUsers();
        for (User user : users) {
            String agency = userMapper.selectAgentName(user.getId());
            user.setAgencyName(agency);
        }
        return users;
    }

    public List<TreeItem> selectAgencyBeTree() {
        return userMapper.selectAgencyBeTree();
    }
}
